import {
  VueAmap,
  // VueDebug,
  VueDialog,
  VueQrcode,
  VueRegion,
  VueShape
} from "@halobear/vue";

// 注入全局组件全局
const components = {
  "vue-amap": VueAmap,
  // "vue-debug": VueDebug,
  "vue-dialog": VueDialog,
  "vue-qrcode": VueQrcode,
  "vue-region": VueRegion,
  "vue-shape": VueShape
};

// 自动引入当前文件夹全部组件
const r = require.context("./", true, /index\.vue/);
r.keys().forEach(key => {
  const name = key
    .replace(/^\.\//, "")
    .replace(/\/index.vue$/, "")
    .replace(/([A-Z])/g, "-$1")
    .toLowerCase();
  components[name] = r(key).default;
});

const install = Vue => {
  Object.entries(components).forEach(([name, component]) => {
    Vue.component(name, component);
  });
};

export default {
  install
};
